package com.pzb.web.controller.market;

import java.util.List;

import com.pzb.wechat.service.IWechatAppletService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pzb.common.annotation.Log;
import com.pzb.common.core.controller.BaseController;
import com.pzb.common.core.domain.AjaxResult;
import com.pzb.common.enums.BusinessType;
import com.pzb.market.domain.MkIntegralSetting;
import com.pzb.market.service.IMkIntegralSettingService;

/**
 * 积分设置Controller
 * 
 * @author Mr_Wu
 * @date 2021-12-29
 */
@RestController
@RequestMapping("/market/integralSetting")
public class MkIntegralSettingController extends BaseController
{
    @Autowired
    private IMkIntegralSettingService mkIntegralSettingService;
    @Autowired
    private IWechatAppletService wechatAppletService;

    /**
     * 获取积分设置详细信息
     */
    @GetMapping
    public AjaxResult getInfo()
    {
        return AjaxResult.success(mkIntegralSettingService.selectMkIntegralSetting(wechatAppletService.getExtAppid()));
    }

    /**
     * 修改积分设置
     */
    @Log(title = "积分设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkIntegralSetting mkIntegralSetting)
    {
        return toAjax(mkIntegralSettingService.updateMkIntegralSetting(mkIntegralSetting));
    }

    /**
     * 状态修改
     */
    @Log(title = "积分设置状态", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody MkIntegralSetting mkIntegralSetting)
    {
        return toAjax(mkIntegralSettingService.updateMkIntegralSetting(mkIntegralSetting));
    }

}
